Ext.namespace("Test");

Ext.onReady(function() {

	var textName = new Ext.form.TextField({

				fieldLabel : 'username'

			});

	var textPwd = new Ext.form.TextField({

				fieldLabel : 'password'

			});

	var myForm = new Ext.FormPanel({

				title : 'JSON',
				renderTo : Ext.getBody(),
				frame : true,
				// height:400 ,
				width : 500,
				items : [textName, textPwd],
				buttons : [{

							text : 'JSON',
							handler : login
						}]

			});

	function login() {
		var reqConfig = {
			url : '../jsp/server/loginServerJSON.jsp',
			jsonData : getJson(),
			callback : function(options, success, response) {
				Ext.Msg.alert('Tips', success + '<br>' + response.responseText);
			}
		};
		Ext.Ajax.request(reqConfig);
	};

	function getJson() {
		var name = textName.getValue();
		var pwd = textPwd.getValue();
		var jsonObj={
			userName:name,
			passWord:pwd
		};
		return jsonObj;
	};

});